package com.jj.message.battle;

import com.jj.config.Constants;
import com.jj.message.AbstractMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;


/**
 * Copyrights: QidianGroup@JJ
 *
 * @author: LuHan
 * @date: 2018/1/15, 10:46
 */
public class BattleMsg extends AbstractMessage {
    private static Logger logger = LoggerFactory.getLogger(BattleMsg.class);

    public String getJsonStr(){
        try {
            if(data == null){
                return null;
            }else{
                return new String(data, Constants.ENCODING);
            }
        } catch (UnsupportedEncodingException e) {
            logger.error("exception", e);
            return null;
        }
    }

    public void setJsonStr(String jsonStr){
        try {
            data = jsonStr.getBytes(Constants.ENCODING);
            setData(data);
        } catch (UnsupportedEncodingException e) {
            logger.error("exception", e);
        }
    }


    @Override
    public String toString() {
        return "BattleMsg{" +
                "data=" + getJsonStr() +
                '}';
    }
}
